package com.lambda;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

/**
 * Created by zhaoben on 2016/12/3.
 */
public class TestFunction {

    public static <T,R> List<R> map (List<T> list, Function<T,R> f){
        List<R> result = new ArrayList<R>();
        for (T t: list) {
            result.add(f.apply(t));
        }
        return result;
    }

    public static void main(String[] args) {
        map(Arrays.asList("zhaoben", "", "zhaoxiaoming"),(String s) -> s.length());
    }
}
